import Speech from 'speak-tts'

const speech = new Speech()
speech.init({
    'volume': 1,
    'lang': 'zh-CN',
    'rate': 0.9,
    'pitch': 1,
})

function play(text) {
    speech.speak({
        text: text,
    })
}

//暂停
function paused() {
    speech.pause();
}

//从暂停处继续播放
function resume() {
    speech.resume();
}

function speaking() {
    return speech.speaking()
}

function cancel() {
    return speech.cancel()
}

export default {
    play,
    paused,
    resume,
    speaking,
    cancel
}